//
// Created by ASUS on 2024/5/17/星期五.
//
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(){
	int n,q;cin>>n>>q;
	vector<int> a(n);
	for(auto&x:a) cin>>x;
	vector<int> ans(n);
	multiset<int> left,right;
	int sl=0,sr=0;
	for(int i=0;i<n;i++){
		if(i&1){
			if(a[i]>*right.begin()){
				sr+=a[i]-*right.begin();
				sl+=*right.begin();
				left.insert(*right.begin());
				right.insert(a[i]);
				right.erase(right.begin());
			}else{
				left.insert(a[i]);
				sl+=a[i];
			}
		}else{
			if(left.empty()){
				right.insert(a[i]);
				sr+=a[i];
			}else if(a[i]<*left.rbegin()){
				sr+=*left.rbegin();
				sl+=a[i]-*left.rbegin();
				right.insert(*left.rbegin());
				left.insert(a[i]);
				left.erase(left.find(*left.rbegin()));
			}else{
				right.insert(a[i]);
				sr+=a[i];
			}
		}
		ans[i]=sr-sl;
	}
	while(q--){
		int k;cin>>k;
		cout<<ans[k-1]<<" ";
	}
	cout<<"\n";
}


signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	cin >> t;
	while (t--) solve();
}